//
//  ViewController.m
//  汤姆猫
//
//  Created by 小白 on 16/2/19.
//  Copyright © 2016年 小白. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageview;

@end

@implementation ViewController
-(void)imganimation:(int)m :(NSString *)imname :(double)time
{
    NSMutableArray *mArr = [[NSMutableArray alloc]init];
    for (int i=0; i<=m; i++) {
        NSString *imgname = [NSString stringWithFormat:@"%@%.2i",imname,i];
        UIImage *img = [UIImage imageNamed:imgname];
        [mArr addObject:img];
    }
    self.imageview.animationRepeatCount = 1;
    self.imageview.animationImages = mArr;
    self.imageview.animationDuration = time;
    [self.imageview startAnimating];

}
- (void)viewDidLoad {
    [super viewDidLoad];
}
- (IBAction)crymbal:(UIButton *)sender {
    NSString *img = @"cymbal_";
    [self imganimation:12 :img :1.2];
}
- (IBAction)drink:(UIButton *)sender {
    NSString *img = @"drink_";
    [self imganimation:80 :img :8.0];
}
- (IBAction)eat:(UIButton *)sender {
    NSString *img = @"eat_";
    [self imganimation:39 :img :3.9];
}

- (IBAction)fart:(UIButton *)sender {
    NSString *img = @"fart_";
    [self imganimation:27 :img :2.7];
}

- (IBAction)pie:(UIButton *)sender {
    NSString *img = @"pie_";
    [self imganimation:23 :img :2.3];
}

- (IBAction)scratch:(UIButton *)sender {
    NSString *img = @"scratch_";
    [self imganimation:55 :img :5.5];
}

- (IBAction)stomach:(UIButton *)sender {
    NSString *img = @"stomach_";
    [self imganimation:33 :img :3.3];
}
- (IBAction)footLeft:(UIButton *)sender {
    NSString *img = @"footLeft_";
    [self imganimation:29 :img :2.9];
}

- (IBAction)footRight:(UIButton *)sender {
    NSString *img = @"footRight_";
    [self imganimation:29 :img :2.9];
}

- (IBAction)nockedout:(UIButton *)sender {
    NSString *img = @"knockout_";
    [self imganimation:80 :img :8.0];
}


- (void)didReceiveMemoryWarning {
    // Dispose of any resources that can be recreated.
}

@end
